import os
import sys
import git


def download(prepare_root_dir: str):
    clone_dir = os.path.join(prepare_root_dir, 'download', 'thirdlibs')
    if os.path.exists(clone_dir):
        return
    git.Repo.clone_from(
        url='https://gitee.com/haocxy/thirdlibs.git',
        to_path=clone_dir,
        progress=lambda op_code, cur_count, max_count, message:
            print(f'Clone git repo (thirdlibs) [{cur_count / max_count * 100}%]:{message}')
    )


def main():
    download(sys.argv[1])


if __name__ == '__main__':
    main()
